﻿using System.Threading.Tasks;
using System;
using System.Collections.Generic;

namespace DotNetImage.Imaging
{
    /// <summary>
    /// Represents the collection of filters to be applied to the subject
    /// </summary>
    public class FilterCollection : List<FilterBase>
    {
        /// <summary>
        /// Image being processed.
        /// </summary>
        protected DotNetImage Subject { get; private set; }

        public void Apply(DotNetImage bmp)
        {
            Subject = bmp;
            Apply();
        }

        public void Apply()
        {
            if (Subject == null)
            {
                throw new NullReferenceException("Subject");
            }
        }

        public static FilterCollection Apply(DotNetImage img, params FilterBase[] filters)
        {
            FilterCollection col = new FilterCollection();
            col.Subject = img;
            col.AddRange(filters);
            col.Apply();
            return col;
        }
    }
}
